# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.


cmake_minimum_required(VERSION 3.18.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
# 1.添加并设置库头文件
set(CMAKE_VERBOSE_MAKEFILE on)
set(libs "${CMAKE_SOURCE_DIR}/../../../libs")

# Declares and names the project.

project("testexfatwrite")

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

file(GLOB_RECURSE c_exfat "./../jni/exfat/*/*.c")
file(GLOB_RECURSE c_fuse  "./../jni/fuse/*/*.c")
add_library( # Sets the name of the library.
        testexfatwrite

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        native-lib.cpp
        #    ${c_exfat}
        #     ${c_fuse}
        )


#include_directories(./../jni/exfat/fuse/methodheader.h)

add_library(exfat STATIC IMPORTED)
add_library(fuse_static STATIC IMPORTED)
add_library(exfat_dump STATIC IMPORTED)
add_library(exfat_fsck STATIC IMPORTED)
add_library(exfat_label STATIC IMPORTED)
add_library(exfat_mkfs STATIC IMPORTED)
add_library(exfat_mount STATIC IMPORTED)



set_target_properties(exfat
        PROPERTIES IMPORTED_LOCATION
        "${libs}/${ANDROID_ABI}/libexfat.a"
        )

set_target_properties(fuse_static
        PROPERTIES IMPORTED_LOCATION
        "${libs}/${ANDROID_ABI}/libfuse_static.a"
        )



set_target_properties(exfat_dump
        PROPERTIES IMPORTED_LOCATION
        "${libs}/${ANDROID_ABI}/libexfat_dump.a"
        )


set_target_properties(exfat_fsck
        PROPERTIES IMPORTED_LOCATION
        "${libs}/${ANDROID_ABI}/libexfat_fsck.a"
        )

set_target_properties(exfat_label
        PROPERTIES IMPORTED_LOCATION
        "${libs}/${ANDROID_ABI}/libexfat_label.a"
        )


set_target_properties(exfat_mkfs
        PROPERTIES IMPORTED_LOCATION
        "${libs}/${ANDROID_ABI}/libexfat_mkfs.a"
        )


set_target_properties(exfat_mount
        PROPERTIES IMPORTED_LOCATION
        "${libs}/${ANDROID_ABI}/libexfat_mount.a"
        )


# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.
#set(c_srcs ${c_libexfat} ${c_exfat})




find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)


#include_directories(${libs}/${ANDROID_ABI}/include)



# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        testexfatwrite

        # Links the target library to the log library
        # included in the NDK.
        exfat_mount
        exfat
        fuse_static
        exfat_dump
        exfat_fsck
        exfat_label
        exfat_mkfs
        ${log-lib})

